package cn.imnaer.service.rest.view.model;

import java.util.ArrayList;
import java.util.List;

import cn.imnaer.service.Interceptor.CommonInterceptor;
import cn.imnaer.service.persistence.model.FriendRelation;
import cn.imnaer.service.persistence.model.TravelNoteComment;

public class TravelNoteCommentDetail implements CommonInterceptor {
	private String travelNotePhotoId;
	private String travelNoteCommentId;
	private String userId;
	private String userName;
	private String content;
	private long createTime;
	private String replyUserId;
	public String getTravelNotePhotoId() {
		return travelNotePhotoId;
	}

	public void setTravelNotePhotoId(String travelNotePhotoId) {
		this.travelNotePhotoId = travelNotePhotoId;
	}

	public String getTravelNoteCommentId() {
		return travelNoteCommentId;
	}

	public void setTravelNoteCommentId(String travelNoteCommentId) {
		this.travelNoteCommentId = travelNoteCommentId;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(long createTime) {
		this.createTime = createTime;
	}

	public String getReplyUserId() {
		return replyUserId;
	}

	public void setReplyUserId(String replyUserId) {
		this.replyUserId = replyUserId;
	}

	public static TravelNoteCommentDetail valueOf(TravelNoteComment travelNoteComment) {
		TravelNoteCommentDetail travelNoteCommentDetail = new TravelNoteCommentDetail();
		travelNoteCommentDetail.setContent(travelNoteComment.getContent());
		travelNoteCommentDetail.setCreateTime(travelNoteComment.getCreateTime());
		travelNoteCommentDetail.setReplyUserId(travelNoteComment.getReplyUserId());
		travelNoteCommentDetail.setTravelNoteCommentId(travelNoteComment.getTravelNoteCommentId());
		travelNoteCommentDetail.setTravelNotePhotoId(travelNoteComment.getTravelNotePhotoId());
		travelNoteCommentDetail.setUserId(travelNoteComment.getUserId());
		travelNoteCommentDetail.setUserName(travelNoteComment.getUserName());
		return travelNoteCommentDetail;
	}

	public TravelNoteComment buildComment() {
		TravelNoteComment travelNoteComment = new TravelNoteComment();
		travelNoteComment.setContent(this.getContent());
		travelNoteComment.setCreateTime(this.getCreateTime());
		travelNoteComment.setReplyUserId(this.getReplyUserId());
		travelNoteComment.setTravelNoteCommentId(this.getTravelNoteCommentId());
		travelNoteComment.setTravelNotePhotoId(this.getTravelNotePhotoId());
		travelNoteComment.setUserId(this.getUserId());
		travelNoteComment.setUserName(this.getUserName());
		return travelNoteComment;
	}

	public static List<TravelNoteCommentDetail> valueOfList(List<TravelNoteComment> travelNoteComments) {
		List<TravelNoteCommentDetail> travelNoteCommentDetails = new ArrayList<TravelNoteCommentDetail>();
		for (TravelNoteComment travelNoteComment : travelNoteComments) {
			travelNoteCommentDetails.add(TravelNoteCommentDetail.valueOf(travelNoteComment));
		}
		return travelNoteCommentDetails;
	}

	@Override
	public void supportInterceptor(List<String> hasPermissionUsers) {

	}

	@Override
	public void collectInterceptor(List<String> collectList) {

	}

	@Override
	public void userNameInterceptor(List<FriendRelation> friendRelations) {
		if (friendRelations != null) {
			for (FriendRelation friendRelation : friendRelations) {
				if (friendRelation.getFriendUserId().equals(userId)) {
					this.setUserName(friendRelation.getNote());
				}
			}
		}
	}

}
